package com.smartleanx.module.hrm.dal.mysql.dingDing;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.smartleanx.module.hrm.dal.dataobject.dingDing.DingColumnValue;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * <p>
 * Mapper 接口
 * </p>
 *
 * @author mybatis-plus
 * @since 2024-11-05
 */
@Mapper
public interface DingColumnValueMapper extends BaseMapper<DingColumnValue> {
//    @Select("select count(distinct id ,date) from ding_column_value dcv" +
//            "  left join ding_user du on du.userid = dcv.userId" +
//            "        left join hrm_employee he on he.ding_user_id = du.id" +
//            "where 1=1 and he.ding_user_id is not null " +
//            " <if test=\"employeeIdList !=null and employeeIdList.size >0 \">\n" +
//            "            and he.id in\n" +
//            "            <foreach collection=\"employeeIdList\" close=\")\" item=\"employeeId\" open=\"(\" separator=\",\">\n" +
//            "                #{employeeId}\n" +
//            "            </foreach>\n" +
//            "        </if>" +
//            " <if test=\"teamIdList !=null and teamIdList.size>0 \">\n" +
//            "            and dcv.group_id in\n" +
//            "            <foreach collection=\"teamIdList\" separator=\",\" open=\"(\" item=\"teamId\" close=\")\">\n" +
//            "                #{teamId}\n" +
//            "            </foreach>\n" +
//            "\n" +
//            "        </if>")
//    Long selectCount(@Param("employeeIdList") List<Integer> employeeIdList,@Param("teamIdList") List<Integer> teamIdList);

    @Select("select count(distinct id ,date) from ding_column_value dcv" +
            "  left join ding_user du on du.userid = dcv.userId" +
            "        left join hrm_employee he on he.ding_user_id = du.id" +
            "where 1=1 and he.ding_user_id is not null " +
            " <if test=\"employeeIdList !=null and employeeIdList.size >0 \">\n" +
            "            and he.id in\n" +
            "            <foreach collection=\"employeeIdList\" close=\")\" item=\"employeeId\" open=\"(\" separator=\",\">\n" +
            "                #{employeeId}\n" +
            "            </foreach>\n" +
            "        </if>" +
            " <if test=\"teamIdList !=null and teamIdList.size>0 \">\n" +
            "            and dcv.group_id in\n" +
            "            <foreach collection=\"teamIdList\" separator=\",\" open=\"(\" item=\"teamId\" close=\")\">\n" +
            "                #{teamId}\n" +
            "            </foreach>\n" +
            "\n" +
            "        </if> group by dcv.userId ")
    Long selectMonthCount(@Param("employeeIdList") List<Integer> employeeIdList,@Param("teamIdList") List<Integer> teamIdList);


}
